//
//  clsGhost.cpp
//  NewMath
//
//  Created by Ngô Hoàng Nam on 12/27/14.
//
//

#include "PlaySelectGhostObj.h"
#include "../../../GamePlayConfig.h"
#include "../PlayConfig.h"

PlaySelectGhostObj::PlaySelectGhostObj(){}

void PlaySelectGhostObj::initGhost(std::string ghostSprite, std::string text, cocos2d::Vec2 Position, float kScale)
{
    BaseGhostObj::initGhost(ghostSprite, Position, kScale);
   
    float newWidthGhost = m_Ghost->getContentSize().width*kScale;
    float newHeightGhost = m_Ghost->getContentSize().height*kScale;
    
    btnNumber = Button::create();
    btnNumber->loadTextures("messagebox.png", "messagebox.png");
    btnNumber->setTitleText(text);
    btnNumber->setTitleColor(Color3B::BLACK);
    btnNumber->setScale(kScale);
    btnNumber->setTitleFontSize((btnNumber->getContentSize().height * kScale)/3);
    btnNumber->setPosition(Vec2(m_Ghost->getPosition().x,m_Ghost->getPosition().y + newHeightGhost));
    btnNumber->addClickEventListener(CC_CALLBACK_1(PlaySelectGhostObj::btnNumber_Click,this));
    btnNumber->runAction(RepeatForever::create(Sequence::create(ScaleTo::create(0.7f, 1.5f),ScaleTo::create(1.0f, 1.2f), NULL)));
    
    this->addChild(btnNumber);

}
void PlaySelectGhostObj::btnNumber_Click(cocos2d::Ref *pSender)
{
    Button* btn = (Button*)pSender;
    std::string value = btn->getTitleText();
	GamePlayConfig::GetInstance()->m_selectNumber = atoi(value.c_str());
    CCLOG("%d",GamePlayConfig::GetInstance()->m_selectNumber);
}
